<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('产品补助金申请记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input id="applyStatus" name="applyStatus" value="0" type="hidden">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>产品名称：</label>
                                <input type="text" name="partsName"/>
                            </li>
                            <li>
                                <label>规格名称：</label>
                                <input type="text" name="attributeId"/>
                            </li>
                            <li>
                                <label style="width: 100px;">申请人电话：</label>
                                <input type="text" name="storePhone"/>
                            </li>
                            <li>
                                <label style="width: 100px;">二维码编码：</label>
                                <input type="text" name="qrcodeId"/>
                            </li>
                            <li>
                                <label>厂家名称：</label>
                                <input type="text" name="factoryName"/>
                            </li>
                            <li>
                                <label>厂家电话：</label>
                                <input type="text" name="factoryPhone"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:partsQrcodeApply:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:partsQrcodeApply:remove')}]];
        var applyStatusDatas = [[${@dict.getType('apply_status')}]];
        var isTransferDatas = [[${@dict.getType('zsyh_yesno')}]];
        var applyChannelDatas = [[${@dict.getType('apply_channel')}]];
        var prefix = ctx + "zsyh/partsQrcodeApply";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                modalName: "产品补助金申请记录",
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: '申请补助金id -- 公众号 订单编号',
                    visible: false
                },
                    {
                        field: 'qrcodeId',
                        align: 'center',
                        title: '二维码编码'
                    },
                    {
                        field: 'attributeLogo',
                        align: 'center',
                        title: '产品主图',
                        formatter: function (value, row, index) {
                            return $.table.imageView(value);
                        }
                    },
                {
                    field: 'attributeName',
                    align: 'center',
                    title: '产品名称'
                },
                /*{
                    field: 'factoryName',
                    title: '厂家名称'
                },*/
                    {
                        field: 'storePhone',
                        align: 'center',
                        title: '申请人联系方式'
                    },
                    {
                        field: 'applyNum',
                        align: 'center',
                        title: '申请次数'
                    },
                /*{
                    field: 'faultImages',
                    title: '故障凭证 url 多个以|隔开'
                },
                {
                    field: 'faultDetails',
                    title: '故障描述'
                },*/
                {
                    field: 'factoryName',
                    align: 'center',
                    title: '厂家名称'
                },
               /* {
                    field: 'factoryPhone',
                    title: '厂家电话'
                },
                {
                    field: 'factoryAddress',
                    title: '厂家地址'
                },*/
                {
                    field: 'applyStatus',
                    align: 'center',
                    title: '状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(applyStatusDatas, value);
                    }
                },
                {
                    field: 'applyChannel',
                    align: 'center',
                    title: '申请渠道',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(applyChannelDatas, value);
                    }
                },
                    {
                        field: 'createTime',
                        align: 'center',
                        title: '申请时间'
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="viewQrcode(\'' + row.qrcodeId + '\')"><i class="fa fa-edit"></i>扫码查看</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="viewOrder(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
                       /* actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');*/
                        if(row.applyStatus == '3'){
                            actions.push('<a class="btn btn-info btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="reviewApply(\'' + row.id + '\')"><i class="fa fa-plus"></i>平台审核</a>');
                        }
                        /*if(row.applyStatus == '6'){
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-mail-forward"></i>转账</a>');
                        }*/
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function viewOrder(id) {
            var url = prefix + "/edit/"+id;
            layer.open({
                type: 2,
                area: [$(window).width()/1.5 + 'px', ($(window).height() - 50) + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看申请详细",
                content: url,
                btnClose: 1,
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    debugger;
                    var iframeWin = layero.find('iframe')[0];
                    var imageUrl = layero.find('iframe')[0].contentWindow.$("#imageUrl").val();
                    iframeWin.contentWindow.submitHandler(index, layero);
                },
                cancel: function(index) {
                    return true;
                }
            });
        }

        function viewQrcode(qrcode) {
            var url = prefix + "/viewQrcode/"+qrcode;
            layer.open({
                type: 2,
                area: ['800px','600px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "扫码查看",
                content: url,
                btnClose: 1,
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    debugger;
                    var iframeWin = layero.find('iframe')[0];
                    var imageUrl = layero.find('iframe')[0].contentWindow.$("#imageUrl").val();
                    iframeWin.contentWindow.submitHandler(index, layero);
                },
                cancel: function(index) {
                    return true;
                }
            });
        }

        function reviewApply(id) {
            var url = prefix + '/reviewApply/'+id;
            layer.open({
                type: 2,
                area: [$(window).width()/2 + 'px', '350px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "平台审核",
                content: url,
                closeBtn: 1,
                /*btn: ['通过', '驳回'],*/
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    debugger;
                    var iframeWin = layero.find('iframe')[0];
                },
                cancel: function(index) {
                    return true;
                }
            });
        }

    </script>
</body>
</html>